﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RoguelikeLib.Maps;

namespace RoguelikeLib
{
    public class Game
    {
        public static Random RNG = new Random();
        public const int MapWidth = 80;
        public const int MapHeight = 40;

        public static IRenderer Renderer { get; set; }
        
        //public static Tile[][] Map
        //{
        //    get
        //    {
        //        if (CurrentDungeon == null)
        //        {
        //            CurrentDungeon = new StandardDungeon();
        //            CurrentDungeon.GenerateMap();
        //        }
        //        return CurrentDungeon.Map;
        //    }
        //}

        internal static StandardDungeon CurrentDungeon { get; set; }
        public static int Roll(int numberOfDie, int minNumber, int maxNumber)
        {
            if (minNumber > maxNumber)
            {
                var tempNumber = maxNumber;
                maxNumber = minNumber;
                minNumber = tempNumber;
            }
            int sum = 0;
            for (int i = 0; i < numberOfDie; i++)
                sum += Game.RNG.Next(minNumber, maxNumber);
            return sum;
        }

        public static void Debug()
        {
            CurrentDungeon.Debug();
        }
        public static void Start()
        {
            try
            {
                CurrentDungeon = new StandardDungeon();
                CurrentDungeon.GenerateMap();
                for (int y = 0; y < CurrentDungeon.Map.Length; y++)
                {
                    var tileRow = CurrentDungeon.Map[y];
                    for (int x = 0; x < tileRow.Length; x++)
                        Renderer.Draw(x, y, tileRow[x].Type);
                }
            }
            catch (Exception ex)
            {
                
                
            }
           
        }

        public static void GetLevel()
        {
            
        }

    }
}
